package weak_20241227_29.stream;

import java.util.ArrayList;

/**
 * @author zdl
 * @date 2024/12/27
 */
public class Demo3 {
    public static void main(String[] args) {
        //3. 计算整数列表中所有偶数的平均值
        ArrayList<Integer> list = new ArrayList<>();
        list.add(2);
        list.add(9);
        list.add(3);
        list.add(20);
        list.add(12);
        Integer sum = list.stream().reduce(0, (i1, i2) -> i1 + i2);
        long count = list.stream().count();
        double avg = sum * 1.0 / count;
        System.out.println(avg);
    }
}
